<template>
  <div class="dashboard">
    <div class="welcome-card">
      <h2>欢迎使用考勤管理系统</h2>
      <p>当前用户：{{ userStore.realName || userStore.username }}（{{ userStore.role === 'ADMIN' ? '管理员' : '普通员工' }}）</p>
      <p>登录时间：{{ loginTime }}</p>
    </div>
    
    <div class="stats-cards">
      <el-row :gutter="20">
        <el-col :span="6">
          <div class="stat-card">
            <div class="stat-icon">
              <el-icon size="30" color="#409eff"><Clock /></el-icon>
            </div>
            <div class="stat-content">
              <h3>班次管理</h3>
              <p>管理工作班次信息</p>
            </div>
          </div>
        </el-col>
        
        <el-col :span="6">
          <div class="stat-card">
            <div class="stat-icon">
              <el-icon size="30" color="#67c23a"><Calendar /></el-icon>
            </div>
            <div class="stat-content">
              <h3>排班表管理</h3>
              <p>管理员工排班计划</p>
            </div>
          </div>
        </el-col>
        
        <el-col :span="6">
          <div class="stat-card">
            <div class="stat-icon">
              <el-icon size="30" color="#e6a23c"><Document /></el-icon>
            </div>
            <div class="stat-content">
              <h3>考勤记录</h3>
              <p>查看打卡和考勤数据</p>
            </div>
          </div>
        </el-col>
        
        <el-col :span="6">
          <div class="stat-card">
            <div class="stat-icon">
              <el-icon size="30" color="#f56c6c"><DataAnalysis /></el-icon>
            </div>
            <div class="stat-content">
              <h3>考勤统计</h3>
              <p>统计分析考勤数据</p>
            </div>
          </div>
        </el-col>
      </el-row>
    </div>
    
    <div class="quick-actions">
      <h3>快捷操作</h3>
      <el-row :gutter="20">
        <el-col :span="8">
          <el-card class="action-card" @click="$router.push('/shift-management')">
            <div class="action-content">
              <el-icon size="24"><Clock /></el-icon>
              <span>班次管理</span>
            </div>
          </el-card>
        </el-col>
        
        <el-col :span="8">
          <el-card class="action-card" @click="$router.push('/schedule-management')">
            <div class="action-content">
              <el-icon size="24"><Calendar /></el-icon>
              <span>排班表管理</span>
            </div>
          </el-card>
        </el-col>
        
        <el-col :span="8">
          <el-card class="action-card" @click="$router.push('/attendance/attendance-records')">
            <div class="action-content">
              <el-icon size="24"><Document /></el-icon>
              <span>考勤记录</span>
            </div>
          </el-card>
        </el-col>
      </el-row>
    </div>
  </div>
</template>

<script setup>
import { computed } from 'vue'
import { useUserStore } from '@/store/user'
import dayjs from 'dayjs'

const userStore = useUserStore()

const loginTime = computed(() => {
  return dayjs().format('YYYY-MM-DD HH:mm:ss')
})
</script>

<style lang="scss" scoped>
.dashboard {
  .welcome-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px;
    border-radius: 8px;
    margin-bottom: 20px;
    
    h2 {
      margin: 0 0 10px 0;
      font-size: 24px;
    }
    
    p {
      margin: 5px 0;
      opacity: 0.9;
    }
  }
  
  .stats-cards {
    margin-bottom: 30px;
    
    .stat-card {
      background: white;
      padding: 20px;
      border-radius: 8px;
      box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
      display: flex;
      align-items: center;
      
      .stat-icon {
        margin-right: 15px;
      }
      
      .stat-content {
        h3 {
          margin: 0 0 5px 0;
          font-size: 16px;
          color: #333;
        }
        
        p {
          margin: 0;
          font-size: 12px;
          color: #666;
        }
      }
    }
  }
  
  .quick-actions {
    h3 {
      margin-bottom: 15px;
      color: #333;
    }
    
    .action-card {
      cursor: pointer;
      transition: all 0.3s;
      
      &:hover {
        transform: translateY(-2px);
        box-shadow: 0 4px 20px 0 rgba(0, 0, 0, 0.15);
      }
      
      .action-content {
        display: flex;
        flex-direction: column;
        align-items: center;
        padding: 20px;
        
        .el-icon {
          margin-bottom: 10px;
          color: #409eff;
        }
        
        span {
          font-size: 14px;
          color: #333;
        }
      }
    }
  }
}
</style>